package com.example.tool.task.networkTool;


import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;
import java.net.URL;
import java.util.Vector;


/**
 * @Author lz
 * @Date 2022/2/22 16:50
 */
public class WebService {


    public static void main(String[] args) throws Exception {
        URL url = new URL("http://www.webxml.com.cn/WebServices/WeatherWS.asmx");
        String soapaction="http://WebXml.com.cn/";
        Service service = new Service();
        Call call = (Call) service.createCall();
        call.setTimeout(5000);
        call.setTargetEndpointAddress(url);
        call.setOperationName(new QName(soapaction,"getSupportCityString"));
        call.addParameter(new QName(soapaction,"theRegionCode"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

        call.setReturnType(new QName(soapaction,"getSupportCityString"), Vector.class);
        call.setUseSOAPAction(true);
        call.setSOAPActionURI(soapaction + "getSupportCityString");
        Vector v = (Vector) call.invoke(new Object[] { "北京" });// 调用方法并传递参数
        for (int i = 0; i < v.size(); i++) {
            System.out.println(v.get(i));
        }

    }





}
